# Contributor: Olliver Schinagl <oliver@schinagl.nl>
# Maintainer: Olliver Schinagl <oliver@schinagl.nl>
pkgname=tpm2-abrmd
pkgver=3.0.0
pkgrel=1
pkgdesc="TPM2 Access Broker & Resource Management Daemon implementing the TCG spec."
url="https://github.com/tpm2-software/tpm2-abrmd"
arch="all"
license="BSD-2-Clause"
depends="dbus libtss2-tcti-armbd"
makedepends="
	glib-dev
	tpm2-tss-dev
	tpm2-tss-mu
	tpm2-tss-rc
	tpm2-tss-sys
	tpm2-tss-tctildr
	"
install="$pkgname.pre-install"
options="!check"  # Requires IBM TPM simulator
subpackages="
	libtss2-tcti-armbd:libs
	$pkgname-dev
	$pkgname-doc
	$pkgname-openrc
"
source="
	https://github.com/tpm2-software/tpm2-abrmd/releases/download/$pkgver/tpm2-abrmd-$pkgver.tar.gz
	$pkgname.confd
	$pkgname.initd
"
prepare() {
	default_prepare
	update_config_sub
}

build() {
	./configure \
		--build="$CBUILD" \
		--host="$CHOST" \
		--prefix="/usr" \
		--with-dbuspolicydir="/usr/share/dbus-1/system.d" \
		-with-systemdpresetdisable
	make
}

package() {
	make DESTDIR="$pkgdir" install
	rm -f -r "$pkgdir/usr/lib/systemd"

	install -D -m 0755 "$srcdir/$pkgname.initd" \
	        "$pkgdir/etc/init.d/$pkgname"
	install -D -m 0644 "$srcdir/$pkgname.confd" \
	        "$pkgdir/etc/conf.d/$pkgname"
}

sha512sums="
65a39cd0518dfbcbd5835ac6c6628444d412e36471702f2cd1f1077d788330a477778e6403899ea2fa0497b643e5db9ca3e746845492eff78c4c78d8dd8f9e7d  tpm2-abrmd-3.0.0.tar.gz
ca7c4782ccc3ee7592bb4b24a6a81c624d22969cf9b9e1c3e22d45e85d3720836b1f22735ccf2ba51258c6eb0b30c4d88d7bed893f58b1aac7423fb7013529f9  tpm2-abrmd.confd
4ccf0a409bc3f92cb9d804a4e380002653e9759e4fa1830e152a8ac46f1039d46229ca80f4fe39ffe4b28a78a36a798a8b081488566a58078af7cbf3a10b14de  tpm2-abrmd.initd
"
